//
//  ConfirmOrdersViewController.m
//  LoveAttention
//
//  Created by 鞠超 on 16/1/5.
//  Copyright © 2016年 JC. All rights reserved.
//

#import "ConfirmOrdersViewController.h"

#import "MJRefresh.h"
#import "DataProvider.h"
#import "SVProgressHUD.h"
#import "UIImageView+WebCache.h"
@interface ConfirmOrdersViewController ()

@property (nonatomic, strong) UILabel * type;

@property (nonatomic, strong) UILabel * time;

@property (nonatomic, strong) UILabel * number;

@property (nonatomic, strong) UILabel * jine;

@property (nonatomic, strong) UIButton * btn_ok;
@end

@implementation ConfirmOrdersViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self p_navigationController];
    
    [self p_setupView];
    
    [self p_data];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navigationController
- (void)p_navigationController
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.navigationItem.title = @"订单确认";
    UIButton * btn = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [btn setBackgroundImage:[UIImage imageNamed:@"返回"] forState:(UIControlStateNormal)];
        btn.frame = CGRectMake(10, 20, 25, 30);
    [btn addTarget:self action:@selector(leftBarButtonItemAction:) forControlEvents:(UIControlEventTouchUpInside)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
}
//点击事件(左)
- (void)leftBarButtonItemAction:(UIBarButtonItem *)bar
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 布局
- (void)p_setupView
{
    UIView * view_bottom = [[UIView alloc] initWithFrame:CGRectMake(0 , 64 + 10, self.view.frame.size.width , 190)];
    view_bottom.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view_bottom];
    
    //选中
    UIImageView * label_1 = [[UIImageView alloc] initWithFrame:CGRectMake(35, 5, 30, 30)];
    label_1.image = [UIImage imageNamed:@"选中"];
    [view_bottom addSubview:label_1];
    
    self.type = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(label_1.frame) + 35, 5, 180, 30)];
    self.type.font = [UIFont systemFontOfSize:15];
    self.type.textColor = [UIColor orangeColor];
    self.type.text = @"哈哈哈哈";
    [view_bottom addSubview:self.type];
    
    UIView * view_1 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.type.frame) + 10, self.view.frame.size.width , 1)];
    view_1.backgroundColor = [UIColor grayColor];
    [view_bottom addSubview:view_1];
    
    //订单编号
    UILabel * label_2 = [[UILabel alloc] initWithFrame:CGRectMake(35, CGRectGetMaxY(view_1.frame) + 8, 70, 30)];
    label_2.text = @"订单编号:";
    label_2.font = [UIFont systemFontOfSize:15];
    label_2.textColor = [UIColor grayColor];
    [view_bottom addSubview:label_2];
    
    self.number = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(label_2.frame) + 15, CGRectGetMaxY(view_1.frame) + 8, 180, 30)];
    self.number.font = [UIFont systemFontOfSize:15];
    self.number.text = @"201522323232";
    [view_bottom addSubview:self.number];
    
    UIView * view_2 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.number.frame) + 10, self.view.frame.size.width , 1)];
    view_2.backgroundColor = [UIColor grayColor];
    [view_bottom addSubview:view_2];
    
    //确认时间
    UILabel * label_3 = [[UILabel alloc] initWithFrame:CGRectMake(35, CGRectGetMaxY(view_2.frame) + 8, 70, 30)];
    label_3.text = @"确认时间:";
    label_3.font = [UIFont systemFontOfSize:15];
    label_3.textColor = [UIColor grayColor];
    [view_bottom addSubview:label_3];
    
    self.time = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(label_3.frame) + 15, CGRectGetMaxY(view_2.frame) + 8, 180, 30)];
    self.time.font = [UIFont systemFontOfSize:15];
    self.time.text = @"11：12";
    [view_bottom addSubview:self.time];
    
    UIView * view_3 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.time.frame) + 10, self.view.frame.size.width , 1)];
    view_3.backgroundColor = [UIColor grayColor];
    [view_bottom addSubview:view_3];
    
    //金额
    UILabel * label_4 = [[UILabel alloc] initWithFrame:CGRectMake(35, CGRectGetMaxY(view_3.frame) + 8, 70, 30)];
    label_4.text = @"金额:";
    label_4.font = [UIFont systemFontOfSize:15];
    label_4.textColor = [UIColor grayColor];
    [view_bottom addSubview:label_4];
    
    self.jine = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(label_4.frame) + 15, CGRectGetMaxY(view_3.frame) + 8, 180, 30)];
    self.jine.font = [UIFont systemFontOfSize:15];
    self.jine.text = @"无备注";
    [view_bottom addSubview:self.jine];
    
    
    self.btn_ok = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_ok.frame = CGRectMake(15, self.view.frame.size.height - 10 - 45, self.view.frame.size.width - 30, 45);
    self.btn_ok.backgroundColor = [UIColor orangeColor];
    [self.btn_ok setTitle:@"确  认" forState:(UIControlStateNormal)];
    [self.btn_ok setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    self.btn_ok.titleLabel.font = [UIFont systemFontOfSize:21];
    [self.view addSubview:self.btn_ok];
    
    [self.btn_ok addTarget:self action:@selector(btn_okAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

- (void)btn_okAction:(UIButton *)sender
{
    NSLog(@"确定");
    
    self.btn_ok.hidden = YES;
#warning 调确认接口， 成功后隐藏btn
}

#pragma mark - 数据
- (void)p_data
{
    DataProvider * dataprovider = [[DataProvider alloc] init];
    
    [dataprovider setDelegateObject:self setBackFunctionName:@"ConfirmOrders:"];
    
    [dataprovider ConfirmOrdersWith:self.orderid];
}

- (void)ConfirmOrders:(id )dict
{
    NSLog(@"%@",dict);
    
    if ([dict[@"status"][@"succeed"] intValue] == 1) {
        @try
        {
            
        }
        @catch (NSException *exception) {
            
        }
        @finally {
            
        }
    }
    else
    {
        [SVProgressHUD showErrorWithStatus:dict[@"status"][@"errdesc"] maskType:SVProgressHUDMaskTypeBlack];
    }
}








@end
